


***********************
*Lin Yao's Data
***********************
cd "C:\linsantu"

use "Wang APSR Master Data.dta", clear
merge 1:1 politician_id using "extend.dta"

gen support_continuous_new=support_continuous
replace support_continuous_new=faction_2 if support_continuous==.

gen support_dummy_new=support_dummy
replace support_dummy_new=faction_2 if support_dummy==.

gen N=0
replace N=1 if area=="N"
gen S=0
replace S=1 if area=="S"
gen W=0
replace W=1 if area=="W"

save "lin_extend.dta"



***********************
*O-sample: *Standardize all variables*
***********************

use "Wang APSR Master Data.dta", clear

global y "support_continuous support_dummy"
global x "kinproximity kinproximity_children kinproximity_politician kinproximity_wd kin_county_w kin_prefecture_w kin_province_w kinproximity_wp1 kinproximity_wp2 kinproximity_wp3 kinproximity_wp4 kinproximity_wp5 kinproximity_wp6 kinproximity_wp7 kinproximity_wp8 kinproximity_wp9"
global controls "rank_change betweenness degree bonacich kin_node children supportfaction kinmedianexposuretoexternal50 kinmedianexposuretointernal50 kinexposuretoexternalwar kinexposuretomassrebel avg_ruggedness father_exam dist_grandfather_father father_official grandfather_official uncle_any_official rank_first rank_ave rank_max"

center $y $x $controls if sample==1, inplace standardize

*clean up all the labels
label var	kin_node	"N of kin"
label var	support_dummy	"Support for reform (dichotomous)"
label var	support_continuous	"Support for reform (continuous)"
label var	kinproximity	"Local concentration of kin"
label var	kinproximity_wp1	"Local concentration of kin (matrilineal discount 0.1)"
label var	kinproximity_wp2	"Local concentration of kin (matrilineal discount 0.2)"
label var	kinproximity_wp3	"Local concentration of kin (matrilineal discount 0.3)"
label var	kinproximity_wp4	"Local concentration of kin (matrilineal discount 0.4)"
label var	kinproximity_wp5	"Local concentration of kin (matrilineal discount 0.5)"
label var	kinproximity_wp6	"Local concentration of kin (matrilineal discount 0.6)"
label var	kinproximity_wp7	"Local concentration of kin (matrilineal discount 0.7)"
label var	kinproximity_wp8	"Local concentration of kin (matrilineal discount 0.8)"
label var	kinproximity_wp9	"Local concentration of kin (matrilineal discount 0.9)"
label var	kinproximity_wd	"Local concentration of kin (relational distance discount)"
label var	kin_county_w	"Herfindahl index of kin concentration (county)"
label var	kin_prefecture_w	"Herfindahl index of kin concentration (prefecture)"
label var	kin_province_w	"Herfindahl index of kin concentration (province)"
label var	degree	"Degree centrality"
label var	betweenness	"Betweenness centrality"
label var	bonacich	"Bonacich power"
label var	supportfaction	"Factional tie with reform leader"
label var	rank_change	"Politician rank change"
label var	father_exam	"Father exam"
label var	father_official	"Father official status"
label var	grandfather_official	"Grandfather official status"
label var	kinexposuretoexternalwar	"Kin exposure to external wars"
label var	kinexposuretomassrebel	"Kin exposure to mass rebellions"
label var	kinmedianexposuretoexternal50	"Kin centroid exposure to external wars"
label var	kinmedianexposuretointernal50	"Kin centroid exposure to mass rebellions"
label var	children	"N of children"
label var	kinproximity_children	"Local concentration of kin/N of children"
label var	avg_ruggedness	"Ruggedness Index"
label var	dist_grandfather_father	"Father migration"
label var	kinproximity_politician	"Local concentration of kin (politician)"
label var	uncle_any_official	"Uncle official status"
label var	rank_first	"Politician's first rank"
label var	rank_ave	"Politician's average rank"
label var	rank_max	"Politician's highest rank"

save "Wang APSR Master Data_st.dta", replace


***********************
*E-sample: *Standardize all variables and clean up all the labels*
***********************

use "lin_extend.dta", clear

global y "support_continuous_new support_dummy_new"
global x "kinproximity kinproximity_children kinproximity_politician kinproximity_wd kin_county_w kin_prefecture_w kin_province_w kinproximity_wp1 kinproximity_wp2 kinproximity_wp3 kinproximity_wp4 kinproximity_wp5 kinproximity_wp6 kinproximity_wp7 kinproximity_wp8 kinproximity_wp9"
global controls "rank_change betweenness degree bonacich kin_node children supportfaction kinmedianexposuretoexternal50 kinmedianexposuretointernal50 kinexposuretoexternalwar kinexposuretomassrebel avg_ruggedness father_exam dist_grandfather_father father_official grandfather_official uncle_any_official rank_first rank_ave rank_max"

center $y $x $controls if faction_2!=., inplace standardize

*clean up all the labels*

label var	kin_node	"N of kin"
label var	support_dummy_new	"Support for reform (dichotomous)"
label var	support_continuous_new	"Support for reform (continuous)"
label var	kinproximity	"Local concentration of kin"
label var	kinproximity_wp1	"Local concentration of kin (matrilineal discount 0.1)"
label var	kinproximity_wp2	"Local concentration of kin (matrilineal discount 0.2)"
label var	kinproximity_wp3	"Local concentration of kin (matrilineal discount 0.3)"
label var	kinproximity_wp4	"Local concentration of kin (matrilineal discount 0.4)"
label var	kinproximity_wp5	"Local concentration of kin (matrilineal discount 0.5)"
label var	kinproximity_wp6	"Local concentration of kin (matrilineal discount 0.6)"
label var	kinproximity_wp7	"Local concentration of kin (matrilineal discount 0.7)"
label var	kinproximity_wp8	"Local concentration of kin (matrilineal discount 0.8)"
label var	kinproximity_wp9	"Local concentration of kin (matrilineal discount 0.9)"
label var	kinproximity_wd	"Local concentration of kin (relational distance discount)"
label var	kin_county_w	"Herfindahl index of kin concentration (county)"
label var	kin_prefecture_w	"Herfindahl index of kin concentration (prefecture)"
label var	kin_province_w	"Herfindahl index of kin concentration (province)"
label var	degree	"Degree centrality"
label var	betweenness	"Betweenness centrality"
label var	bonacich	"Bonacich power"
label var	supportfaction	"Factional tie with reform leader"
label var	rank_change	"Politician rank change"
label var	father_exam	"Father exam"
label var	father_official	"Father official status"
label var	grandfather_official	"Grandfather official status"
label var	kinexposuretoexternalwar	"Kin exposure to external wars"
label var	kinexposuretomassrebel	"Kin exposure to mass rebellions"
label var	kinmedianexposuretoexternal50	"Kin centroid exposure to external wars"
label var	kinmedianexposuretointernal50	"Kin centroid exposure to mass rebellions"
label var	children	"N of children"
label var	kinproximity_children	"Local concentration of kin/N of children"
label var	avg_ruggedness	"Ruggedness Index"
label var	dist_grandfather_father	"Father migration"
label var	kinproximity_politician	"Local concentration of kin (politician)"
label var	uncle_any_official	"Uncle official status"
label var	rank_first	"Politician's first rank"
label var	rank_ave	"Politician's average rank"
label var	rank_max	"Politician's highest rank"

save "lin_extend_st.dta"

************************************
*TABLE 2. OLS Estimates of the Correlation between Father Migration and Geography of Kinship Network*
************************************

use "Wang APSR Master Data_st.dta", clear
local controls "i.hometown_prefecture_id"

xi: reg kinproximity dist_grandfather_father if sample==1,cl(hometown_prefecture_id)
estimates store table21

xi: reg kinproximity dist_grandfather_father `controls' if sample==1,cl(hometown_prefecture_id)
estimates store table22

use "lin_extend_st.dta", clear
local controls "i.hometown_prefecture_id"

xi: reg kinproximity dist_grandfather_father if faction_2!=.,cl(hometown_prefecture_id)
estimates store table23

xi: reg kinproximity dist_grandfather_father `controls' if faction_2!=.,cl(hometown_prefecture_id)
estimates store table24

esttab table21 table22 table23 table24 using table2.rtf, ///
	replace keep(dist_grandfather_father) ///
	b(3) se(3) ///
	cells(b(star fmt(3)) se(fmt(3) par)) staraux star(* 0.10 ** 0.05 *** 0.01) collabels(none) ///
	label noconstant obslast nodepvars nomtitles nogaps /// 
	scalars("r2 \(R^{2}\)") sfmt(3) ///
	stats(N r2, fmt(3 3 0 3) labels("Outcome mean" "Outcome std.dev." "Observations" "R2")) ///
	indicate("Prefecture FE = *Ihometown*")

************************************
*TABLE 3. OLS Estimates of the Correlation between Geography of Kinship Network and Support for Reform (O-Sample vs. E-Sample)
************************************
use "Wang APSR Master Data_st.dta", clear
local controls1 "i.hometown_prefecture_id"
local controls2 "betweenness kin_node children supportfaction rank_ave kinmedianexposuretoexternal50 kinmedianexposuretointernal50  avg_ruggedness father_exam dist_grandfather_father i.hometown_prefecture_id"
xi: reg support_dummy kinproximity if sample==1, cl(hometown_prefecture_id)
estimates store table31

xi: reg support_dummy kinproximity `controls1' if sample==1,cl(hometown_prefecture_id)
estimates store table32

xi: reg support_dummy kinproximity `controls2' if sample==1,cl(hometown_prefecture_id)
estimates store table33

pdslasso support_dummy kinproximity _Ihometown__11123-_Ihometown__101191 ///
(betweenness kin_node children supportfaction kinmedianexposuretoexternal50 kinmedianexposuretointernal50  avg_ruggedness father_exam dist_grandfather_father) if sample==1,cl(hometown_prefecture_id)
estimates store table34

use "lin_extend_st.dta", clear
local controls1 "i.hometown_prefecture_id"
local controls2 "betweenness kin_node children supportfaction rank_ave kinmedianexposuretoexternal50 kinmedianexposuretointernal50  avg_ruggedness father_exam dist_grandfather_father i.hometown_prefecture_id"
xi: reg support_dummy_new kinproximity if faction_2!=., cl(hometown_prefecture_id)
estimates store table35

xi: reg support_dummy_new kinproximity `controls1' if faction_2!=.,cl(hometown_prefecture_id)
estimates store table36

xi: reg support_dummy_new kinproximity `controls2' if faction_2!=.,cl(hometown_prefecture_id)
estimates store table37

pdslasso support_dummy_new kinproximity _Ihometown__11123-_Ihometown__101191 (betweenness kin_node children supportfaction kinmedianexposuretoexternal50 kinmedianexposuretointernal50  avg_ruggedness father_exam dist_grandfather_father) if faction_2!=.,cl(hometown_prefecture_id)
estimates store table38

esttab table31 table32 table33 table34 table35 table36 table37 table38 using table3.rtf, ///
	replace keep(kinproximity betweenness kin_node children supportfaction rank_ave kinmedianexposuretoexternal50 kinmedianexposuretointernal50  avg_ruggedness father_exam dist_grandfather_father) ///
	b(3) se(3) ///
	cells(b(star fmt(3)) se(fmt(3) par)) staraux star(* 0.10 ** 0.05 *** 0.01) collabels(none) ///
	label noconstant obslast nodepvars nomtitles nogaps /// 
	scalars("r2 \(R^{2}\)") sfmt(3) ///
	stats(ymean ysd N r2, fmt(3 3 0 3) labels("Outcome mean" "Outcome std.dev." "Observations" "R2")) ///
	indicate("Prefecture FE = *Ihometown*")

************************************
*TABLE 5. OLS Estimates of the Correlation between Geography of Kinship Network and Support for Reform (O-Sample Excluding either Lü Gongzhu or Both Lü Brothers)
************************************
use "Wang APSR Master Data_st.dta", clear
local controls1 "i.hometown_prefecture_id"
local controls2 "betweenness kin_node children supportfaction rank_ave kinmedianexposuretoexternal50 kinmedianexposuretointernal50  avg_ruggedness father_exam dist_grandfather_father i.hometown_prefecture_id"

xi: reg support_dummy kinproximity if sample==1 & name_fanti!="呂公著", cl(hometown_prefecture_id)
estimates store table51

xi: reg support_dummy kinproximity `controls1' if sample==1 & name_fanti!="呂公著", cl(hometown_prefecture_id)
estimates store table52

xi: reg support_dummy kinproximity `controls2' if sample==1 & name_fanti!="呂公著", cl(hometown_prefecture_id)
estimates store table53

pdslasso support_dummy kinproximity _Ihometown__11123-_Ihometown__101191 (betweenness kin_node children supportfaction ///
kinmedianexposuretoexternal50 kinmedianexposuretointernal50  avg_ruggedness father_exam dist_grandfather_father) if sample==1 & name_fanti!="呂公著",cl(hometown_prefecture_id)
outreg2 support_continuous kinproximity using "C:\Users\Kang Siqin\Dropbox\study\review\tushi\results table\table2.1.doc", dec(3)
estimates store table54

local controls1 "i.hometown_prefecture_id"
local controls2 "betweenness kin_node children supportfaction rank_ave kinmedianexposuretoexternal50 kinmedianexposuretointernal50  avg_ruggedness father_exam dist_grandfather_father i.hometown_prefecture_id"

xi: reg support_dummy kinproximity if sample==1 & name_fanti!="呂公著" & name_fanti!="呂公弼", cl(hometown_prefecture_id)
estimates store table55

xi: reg support_dummy kinproximity `controls1' if sample==1 & name_fanti!="呂公著" & name_fanti!="呂公弼", cl(hometown_prefecture_id)
estimates store table56

xi: reg support_dummy kinproximity `controls2' if sample==1 & name_fanti!="呂公著" & name_fanti!="呂公弼", cl(hometown_prefecture_id)
estimates store table57

pdslasso support_dummy kinproximity _Ihometown__11123-_Ihometown__101191 (betweenness kin_node children supportfaction ///
kinmedianexposuretoexternal50 kinmedianexposuretointernal50  avg_ruggedness father_exam dist_grandfather_father) if sample==1 & name_fanti!="呂公著" & name_fanti!="呂公弼",cl(hometown_prefecture_id)
estimates store table58

esttab table51 table52 table53 table54 table55 table56 table57 table58 using table5.rtf, ///
	replace keep(kinproximity betweenness kin_node children supportfaction rank_ave kinmedianexposuretoexternal50 kinmedianexposuretointernal50  avg_ruggedness father_exam dist_grandfather_father) ///
	b(3) se(3) ///
	cells(b(star fmt(3)) se(fmt(3) par)) staraux star(* 0.10 ** 0.05 *** 0.01) collabels(none) ///
	label noconstant obslast nodepvars nomtitles nogaps /// 
	scalars("r2 \(R^{2}\)") sfmt(3) ///
	stats(N r2, fmt(3 3 0 3) labels("Observations" "R2")) ///
	indicate("Prefecture FE = *Ihometown*")

************************************
*TABLE 6. OLS Estimates of the Correlation between Geography of Kinship Network and Support for Reform (E-Sample Excluding either Lü Gongzhu or Both Lü Brothers)
************************************
use "lin_extend_st.dta", clear

local controls1 "i.hometown_prefecture_id"
local controls2 "betweenness kin_node children supportfaction rank_ave kinmedianexposuretoexternal50 kinmedianexposuretointernal50  avg_ruggedness father_exam dist_grandfather_father i.hometown_prefecture_id"

xi: reg support_dummy_new kinproximity if faction_2!=. & name_fanti!="呂公著", cl(hometown_prefecture_id)
estimates store table61

xi: reg support_dummy_new kinproximity `controls1' if faction_2!=. & name_fanti!="呂公著", cl(hometown_prefecture_id)
estimates store table62

xi: reg support_dummy_new kinproximity `controls2' if faction_2!=. & name_fanti!="呂公著", cl(hometown_prefecture_id)
estimates store table63

pdslasso support_dummy_new kinproximity _Ihometown__11123-_Ihometown__101191 (betweenness kin_node children supportfaction ///
kinmedianexposuretoexternal50 kinmedianexposuretointernal50  avg_ruggedness father_exam dist_grandfather_father) if faction_2!=. & name_fanti!="呂公著",cl(hometown_prefecture_id)
outreg2 support_continuous kinproximity using "C:\Users\Kang Siqin\Dropbox\study\review\tushi\results table\table2.1.doc", dec(3)
estimates store table64

xi: reg support_dummy_new kinproximity if faction_2!=. & name_fanti!="呂公著" & name_fanti!="呂公弼", cl(hometown_prefecture_id)
estimates store table65

xi: reg support_dummy_new kinproximity `controls1' if faction_2!=. & name_fanti!="呂公著" & name_fanti!="呂公弼", cl(hometown_prefecture_id)
estimates store table66

xi: reg support_dummy_new kinproximity `controls2' if faction_2!=. & name_fanti!="呂公著" & name_fanti!="呂公弼", cl(hometown_prefecture_id)
estimates store table67

pdslasso support_dummy_new kinproximity _Ihometown__11123-_Ihometown__101191 (betweenness kin_node children supportfaction ///
kinmedianexposuretoexternal50 kinmedianexposuretointernal50  avg_ruggedness father_exam dist_grandfather_father) if faction_2!=. & name_fanti!="呂公著" & name_fanti!="呂公弼",cl(hometown_prefecture_id)
estimates store table68

esttab table61 table62 table63 table64 table65 table66 table67 table68 using table6.rtf, ///
	replace keep(kinproximity betweenness kin_node children supportfaction rank_ave kinmedianexposuretoexternal50 kinmedianexposuretointernal50  avg_ruggedness father_exam dist_grandfather_father) ///
	b(3) se(3) ///
	cells(b(star fmt(3)) se(fmt(3) par)) staraux star(* 0.10 ** 0.05 *** 0.01) collabels(none) ///
	label noconstant obslast nodepvars nomtitles nogaps /// 
	scalars("r2 \(R^{2}\)") sfmt(3) ///
	stats(N r2, fmt(3 3 0 3) labels("Observations" "R2")) ///
	indicate("Prefecture FE = *Ihometown*")

************************************
*TABLE 7. OLS Estimates of the Correlation between either Hometown Region or Geography of Kinship Network and Support for Reform (E-Sample)
************************************
use "lin_extend_st.dta", clear
local controls2 "betweenness kin_node children supportfaction rank_ave kinmedianexposuretoexternal50 kinmedianexposuretointernal50  avg_ruggedness father_exam dist_grandfather_father"
xi: reg support_dummy_new S W if faction_2!=., robust
estimates store table71

xi: reg support_dummy_new kinproximity if faction_2!=., robust
estimates store table72

xi: reg support_dummy_new S W kinproximity if faction_2!=., robust
estimates store table73

xi: reg support_dummy_new S W kinproximity i.area `controls2' if faction_2!=., robust
estimates store table74

pdslasso support_dummy_new S W kinproximity (betweenness kin_node children supportfaction kinmedianexposuretoexternal50 kinmedianexposuretointernal50  avg_ruggedness father_exam dist_grandfather_father) if faction_2!=., robust
estimates store table75

esttab table71 table72 table73 table74 table75 using table7.rtf, ///
	replace keep(S W kinproximity betweenness kin_node children supportfaction rank_ave kinmedianexposuretoexternal50 kinmedianexposuretointernal50  avg_ruggedness father_exam dist_grandfather_father) ///
	b(3) se(3) ///
	cells(b(star fmt(3)) se(fmt(3) par)) staraux star(* 0.10 ** 0.05 *** 0.01) collabels(none) ///
	label noconstant obslast nodepvars nomtitles nogaps /// 
	scalars("r2 \(R^{2}\)") sfmt(3) ///
	stats(N r2, fmt(3 3 0 3) labels("Observations" "R2"))


************************************
*Table 8. OLS Estimates of the Correlation between Hometown Region and Geography of Kinship Network (O-Sample vs. E-Sample)
************************************
use "Wang APSR Master Data_st.dta", clear
merge 1:1 politician_id using "extend.dta"
gen N=0
replace N=1 if area=="N"
gen S=0
replace S=1 if area=="S"
gen W=0
replace W=1 if area=="W"

xi: reg kinproximity S W if sample==1, robust
estimates store table81

use "lin_extend_st.dta", clear
xi: reg kinproximity S W if faction_2!=., robust
estimates store table82

esttab table81 table82 using table8.rtf, ///
	replace keep(S W _cons) ///
	b(3) se(3) ///
	cells(b(star fmt(3)) se(fmt(3) par)) staraux star(* 0.10 ** 0.05 *** 0.01) collabels(none) ///
	label obslast nodepvars nomtitles nogaps /// 
	scalars("r2 \(R^{2}\)") sfmt(3) ///
	stats(N r2, fmt(3 3 0 3) labels("Observations" "R2"))
